package edu.asu.cse360.model;

import java.io.Serializable;
import java.util.List;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;


@Entity
@javax.persistence.Table(name="restaurant")
public class Restaurant implements Serializable{


    @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    @Column(name="restaurant_id")
    private Integer id;

    @ManyToMany(fetch=FetchType.LAZY)
    @JoinTable(name="restaurant_tbl",
                    joinColumns=@JoinColumn(name="restaurant_id"),
                    inverseJoinColumns=@JoinColumn(name="tbl_id"))
    private List<Table> tables;

    @OneToOne(fetch=FetchType.LAZY)
    @JoinTable(name="restaurant_manager",
                    joinColumns=@JoinColumn(name="restaurant_id"),
                    inverseJoinColumns=@JoinColumn(name="manager_id"))
    private Manager manager;

    @OneToOne(fetch=FetchType.LAZY)
    @JoinColumn(name="menu_id")
    private Menu menu;

    @OneToMany(fetch=FetchType.LAZY)
    @JoinColumn(name="restaurant_id")
    private Set<Employee> employees;


    public void setId(Integer id) {
            this.id = id;
    }

    public Integer getId() {
            return id;
    }

    public void setTables(List<Table> tables) {
            this.tables = tables;
    }

    public List<Table> getTables() {
            return tables;
    }


    /**
     * @return the manager
     */
    public Manager getManager() {
        return manager;
    }

    /**
     * @param manager the manager to set
     */
    public void setManager(Manager manager) {
        this.manager = manager;
    }

    /**
     * @return the menu
     */
    public Menu getMenu() {
        return menu;
    }

    /**
     * @param menu the menu to set
     */
    public void setMenu(Menu menu) {
        this.menu = menu;
    }

    /**
     * @return the employees
     */
    public Set<Employee> getEmployees() {
        return employees;
    }

    /**
     * @param employees the employees to set
     */
    public void setEmployees(Set<Employee> employees) {
        this.employees = employees;
    }


    @Override
    public String toString(){
            StringBuffer stringRep = new StringBuffer("Restaurant:{");
            stringRep.append("id:").append(id);
            stringRep.append("\n");
            return stringRep.append("}").toString();
    }
}
